<!DOCTYPE html>
<html class="x-admin-sm">
	{include file="public/_header" /}
	<!-- 配置文件 -->
	<script type="text/javascript" src="__STATIC__/static/ueditor/ueditor.config.js"></script>
	<!-- 编辑器源码文件 -->
	<script type="text/javascript" src="__STATIC__/static/ueditor/ueditor.all.js"></script>
	<script type="text/javascript">
		var ROOT = "__STATIC__/admin/";
	</script>
	<style type="text/css">
		.layui-table th {
			background: #f5f7fa;
		}

		.table-form .layui-input,
		.table-form .layui-select,
		.table-form .layui-textarea {
			height: 32px;
			line-height: 1;
		}

		.layui-layout-admin {
			position: fixed;
			left: 0px;
			right: 0;
			bottom: 0px;
			height: 40px;
			line-height: 40px;
			padding: 10px 15px;
			background-color: #fff;
			text-align: center;
			z-index: 1000;
			border-top: 1px solid #ddd;
		}

		.pics-item {
			/* padding: 10px;/ */
		}

		.pics {
			width: 100px;
			height: 80px;
			float: left;
			padding: 10px 4px;
			padding-bottom: 20px;
		}

		.pics img {
			border: 1px solid #eee;
			border-bottom: none;
			width: 100%;
			height: 100%;
		}

		.pics span input {
			width: 98px;
			display: inline-block;
		}

		.layui-upload-list {
			margin: 0 !important;
			float: left;
		}

		.layui-upload-img {
			width: 35px;
			height: 28px;
			margin: 0 10px;
			border: 1px solid #ddd
		}
	</style>
	<body>
		<form class="layui-form" action="">
			<div>
				<div class="layui-row layui-col-space15" style="padding-bottom: 80px;">
					<div class="layui-col-md8">
						<div class="layui-card">
							<div class="layui-card-body">
								<div class="layui-form">

									<table class="layui-table table-form">
										<colgroup>
											<col width="100">
											<col>
										</colgroup>
										<tbody>
											<?php foreach($data as $key=>$value):?>
											<?php switch ($value['type']) {
													case 20:
														title_temp($value,$content);
														break;
													case 1:
														input_temp($value,$content);
														break;
													case 2:
														checked_temp($value,$content);
														break;
													case 3:
														text_temp($value,$content);
														break;
													case 5:
														input_temp($value,$content);
														break;
													case 6:
														input_temp($value,$content);
														break;
													
													case 12:
														thumbs_temp($value,$content);
														break;
													case 13:
														input_temp($value,$content);
														break;
													case 15:
														input_temp($value,$content);
														break;
													case 16:
														input_temp($value,$content);
														break;
													case 11:
														edit_temp($value,$content);
														break;
													case 15:
														mini_edit_temp($value,$content);
														break;
												} ?>

											<?php endforeach ;?>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-col-md4">
						<div class="layui-card">
							<div class="layui-card-body">
								<div class="layui-form">

									<table class="layui-table table-form">
										<colgroup>
											<col width="100">
											<col>
										</colgroup>
										<tbody>
											<?php foreach($data as $key=>$value):?>
											<?php switch ($value['type']) {
													case 8:
														thumb_temp($value,$content);
														break;
													case 9:
														input_temp($value,$content);
														break;
													case 4:
														radio_temp($value,$content);
														break;
													case 10:
														time_temp($value,$content);
														break;
												} ?>
											
											<?php endforeach ;?>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-layout-admin">
				<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
				<button class="layui-btn" id="close">关闭</button>
			</div>
		</form>
	</body>
	<script>
		var id = {$id};
		var modelId = {$model_id};
		
		layui.use(['form'], function() {
			var form = layui.form;
			var $ = layui.jquery;
			//监听提交
			form.on('submit(formDemo)', function(data) {
				if(data.field.file == ""){
					delete data.field.file
				}
				data.field.cid = id
				data.field.model_id = modelId
				
				
				var lfc = top.layerFrameConfig;
				var info = lfc.iframeB.info;
				var index = lfc.iframeB.index;
				$.post("{:url('admin/Article/add_data')}",data.field,function(res){
					if(res.status == 0){
						layer.msg(res.message,{time:500,icon:1},function(){
							info.reload()
							parent.parent.layer.close(index);
						})
					}else{
						layer.msg(res.message,{time:3000,icon:2})
					}
				})
				return false;
			});
			$(document).on('click','#close',function(){
				parent.parent.layer.closeAll();
				return false;  
			});
		});
	</script>

</html>
